<?php
/**
 * Created by PhpStorm.
 * Author: yostar
 * User: THINK
 * Date: 2018/6/4
 * Time: 10:14
 */

namespace wechat\model;

require_once 'Common.php';

class Menu extends Common
{
    /**
     * 自定义菜单创建
     * @param $data
     * @return bool
     */
    public function create_menu($data)
    {
        $create_menu_url = $this->formatUrlWithToken($this->wechat_config['createMenuUrl']);
        $result = $this->curl_post($data, $create_menu_url);
        if ($result) {
            if ($result['errcode'] == 0) {
                return true;
            } else {
                return false;
            }
        }
    }

    /**
     * 自定义菜单查询
     * @return mixed
     */
    public function get_menu()
    {
        $get_menu_url = $this->formatUrlWithToken($this->wechat_config['getMenuUrl']);
        $result = $this->curl_get($get_menu_url);
        return $result;
    }

    /**
     * 自定义菜单删除
     * @return bool
     */
    public function delete_menu()
    {
        $delte_menu_url = $this->formatUrlWithToken($this->wechat_config['deleteMenuUrl']);
        $result = $this->curl_get($delte_menu_url);
        if ($result['errcode'] == 0) {
            return true;
        } else {
            return false;
        }
    }
}